/**
 * @author Sebastian
 * @version 2.0
 * @date 2024/7/16 10:04
 */
// 翻转二叉树
    // https://leetcode.cn/problems/invert-binary-tree/
public class Solution226 {
    public TreeNode invertTree(TreeNode root) {
        if (root == null) return null;
        invertTree(root.left);
        invertTree(root.right);
        swapChild(root);
        return root;
    }

    private void swapChild(TreeNode root) {
        TreeNode tmp = root.left;
        root.left = root.right;
        root.right = tmp;
    }
}
